package com.ycsj.goldmedalnewconcept.teacher.fragment;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.ycsj.common.base.BaseLazyFragment;
import com.ycsj.common.manager.BqaManager;
import com.ycsj.common.manager.SrfManager;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.teacher.adapter.RvYqzAdapter;
import com.ycsj.goldmedalnewconcept.teacher.bean.ByqzInfo;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 被邀请者
 * Created by Administrator on 2019/4/2 0002.
 */

public class TeacherYqzFragment extends BaseLazyFragment {

    @BindView(R.id.rv)
    RecyclerView rv;
    @BindView(R.id.srf)
    SmartRefreshLayout srf;

    //数据集合
    private List<ByqzInfo> oldDatas;

    //空视图
    private View emptyView;
    //适配器
    private RvYqzAdapter adapter;


    //单体模式
    private static class LazyHolder {
        private static final TeacherYqzFragment INSTANCE = new TeacherYqzFragment();
    }

    public static final TeacherYqzFragment newInstance() {
        return TeacherYqzFragment.LazyHolder.INSTANCE;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_teacher_yqz;
    }

    @Override
    public void lazyInit(View view, Bundle savedInstanceState) {

    }


    @Override
    protected void init(View view, Bundle savedInstanceState) {
        super.init(view, savedInstanceState);

        //初始化下拉刷新
        initSrf();

        //初始化列表
        initRv();
    }


    /**
     * 初始化下拉刷新
     */
    private void initSrf() {
        SrfManager.setSmartByPullListener(srf, null);
    }

    /**
     * 初始化列表
     */
    private void initRv() {
        oldDatas = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            ByqzInfo info = new ByqzInfo();
            oldDatas.add(info);
        }
        emptyView = View.inflate(getContext(), R.layout.base_rv_common_empty_view_white_bg, null);
        adapter = new RvYqzAdapter(getContext(), R.layout.rv_item_yqz, oldDatas);
        BqaManager.setRv(emptyView, getContext(), adapter, rv);
    }

}
